<%@page import="java.awt.print.Printable"%>
<%@ page contentType="text/html;charset=UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="shiro" uri="http://shiro.apache.org/tags"%>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions"%>
<%@ taglib prefix="tags" tagdir="/WEB-INF/tags"%>
<c:set var="ctx" value="${pageContext.request.contextPath}" />
<html>
<head>
<meta HTTP-EQUIV="pragma" CONTENT="no-cache">
<meta HTTP-EQUIV="Cache-Control" CONTENT="no-cache, must-revalidate">
<meta HTTP-EQUIV="expires" CONTENT="0">
<%
response.setHeader("Cache-Control","no-store");
response.setHeader("Pragrma","no-cache");
response.setDateHeader("Expires",0);
%>
<title>买单</title>
<script type="text/javascript">
  $(function() {
	  $("#txt_expressNo").focus();
  });
  
  //发货
  function send_weight(){
  
	  var sku=$("#txt_sku").val();
	  
	  if(sku==''){
		  $("#txt_sku").select();
		  $("#txt_sku").focus();
		  $("#msg_sku").html("请录入条码!");
	  }
	  
	  
	  $.ajax({
			type:'post',
			url:'${ctx}/sendTask/buyinfo',
			data:{
				sku:sku
			},
			dataType:'json',
			success:function(data) {
				var msg=data.msg;
				
				if(msg=='success'){
					//显示订单信息
					var buyinfo=data.buyInfo;
				    showBuyInfo(buyinfo);
				    
				    $("#txt_sku").val('');
					$("#txt_sku").focus();
				    
					$("#msg_sku").css("color","green");
					$("#msg_sku").html("成功");
				}
				
			},
			error:function() {
				alert("网络繁忙，请稍后重试...");
			}
	   });
  }
  
  function showOrderInfo(workOrder){
     
      
      $("#orderno").html(workOrder.order.ordeno);
      $("#expressNo").html(workOrder.expressNo);
      $("#expressName").html(workOrder.order.cacode);
      $("#address").html(workOrder.order.addres);
      $("#area").html(workOrder.order.provna+"/"+workOrder.order.cityna+"/"+workOrder.order.distna);
      $("#postco").html(workOrder.order.postco);
      $("#custna").html(workOrder.order.custna);
      $("#mobile").html(workOrder.order.mobile);
      $("#teleph").html(workOrder.order.teleph);
      
      
 }
  
  function keydown(){
	  
	  $("[name='exist']").hide();
      $("[name='noexist']").show();
      
      $("#msg_expressNo").html('');
	  
  }
  
</script>
</head>

<body>
<section class="content">
	<div class="row">
	<div class="col-md-12">
			<!-- Primary box -->
			<div class="box box-solid box-primary" >
				<div class="box-header">
					<i class="fa fa-search"></i>
					<h3 class="box-title">买单</h3>
				</div>
				<div class="box-body">
			<div class="form-group row">
		     <div class="col-sm-3">
				<div class="input-textgroup col-sm-12">
		   		 <span class="input-group-text"> 条码：</span>
		   		  <input type="text" class="form-control" id="txt_sku" onchange="send_weight();" />
		   		</div>
		   		 
		   	<div class="col-sm-3">
				<div class="input-group col-sm-12">
		      <span style="color: red;font-weight: bold;" id="msg_sku"></span>
		      <input type='button' name='重新开始' onclick='refresh();'>
		      </div>
		 	</div>
			</div>
		</div>
	</div></div>
	</div>			 
	
	
	<div class="form-group row">
		<div class="col-md-12">
			<div class="box box-solid box-primary">
				<div class="box-header">
					<i class="fa fa-list"></i>
					<h3 class="box-title">购买信息</h3>
					<div class="box-tools pull-right">
						
					</div>
				</div>
	<div class="box-body">
	<table id="contentTable" class="table table-striped table-bordered table-condensed">
		<thead>
		<tr>
			<th>条码</th>
			<th>商品名</th>
			<th>单价</th>
			<th>数量</th>
		</tr>
		</thead>
		<tbody>
		<tr id="sku_list_id">
		    
		  </tr>
		  </tbody>
	</table>
	</div>
	</div>
	</div>
	</div>
</section>
</body>
</html>
